home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 019a / amac40.zip / SM.QM < prev    next >
Text File  |  1991-07-10  |  21KB  |  461 lines

  1. *                                SM.QM  ver. L             July 10, 1991
  2. * ┌────────────────────────────── (Index) ─────────────────────────────┐
  3. * │
  4. * │ @(6)  Search from command line, load files w/search text,
  5. * │                    **** MUST use SM.BAT ****
  6. * │
  7. * │ (f4)  Finds search text in file after loading
  8. * │
  9. * │ (f5)  PrevFile
  10. * │
  11. * │ (f6)  NextFile
  12. * │
  13. * │ @(h)  Finds first word on cursor line marked in document below
  14. * │
  15. * │ (Description)
  16. * │ (Syntax)
  17. * │ (Mode)
  18. * │ (Required)
  19. * │ (Options) - MaxFind
  20. * │ (NOTE)
  21. * │ (Examples)
  22. * │ (Index) use with @h
  23. * │ (MaxFind) description
  24. * │ (PCED) synonymns to search from a file list
  25. * │ (Other) macros:
  26. * │ (ENVIRONMENT) Variables - See SRCHxx.QM for discussion             |K
  27. * │ (REQUIRED) PROGRAM FILES
  28. * │ (CAUTION) ***********
  29. * │ (Version) history
  30. * └────────────────────────────────────────────────────────────────────┘
  31.  
  32.  
  33. * (DESCRIPTION):
  34. *
  35. * SM.QM are QEdit macros to search files containing a search string using
  36. * MaxFind. Files are searched, found, and loaded for editing or viewing.
  37. * The search string, file names, and other input or search options may be
  38. * specified at the command line or entered at the option query prompt.
  39. * "Fuzzy", "and/or", and "sliding window" text searches can be done.
  40. *
  41. * To run, type "sm" <enter>, and answer the prompts. Press F4 to
  42. * view the search string in each file after finding. Alternatively,
  43. * parameters may be specified at the command line.
  44.  
  45. * 1) SYNTAX:                           SM.BAT %1 %2 %3
  46. *                                   ┌──────────┘  │  └───────────┐
  47. *              (Mode)              %1            %2             %3
  48. *                             Search Text     File Name       Option
  49. *          ----------------   -------------   ----------      -------
  50. *       a) Query              <------- all inputs at prompts ------->
  51. *       b) Partial Query      Search Text        [ ]            [ ]
  52. *       c) Partial Query      Search Text        [ ]          default
  53. *       d) Command line       Search Text     File Name       default
  54. *       e) All command line   Search Text     File Name         [ ]
  55. *
  56. *          where:    %1  - Search Text
  57. *                    %2  - File Name, wild cards OK
  58. *                    %3  - MAXFIND options entered without minus
  59. *                    [ ] - entered at query prompt
  60. * 2) Requires MAXFIND MF.EXE and INPUT.COM
  61. * 3) File Name wild cards OK.
  62. * 4) MAXFIND options can be input at option prompt or %3, default option "ltn"
  63. * 5) Set environment variable OPT=off to bypass MAXFIND option query prompt
  64. *
  65.  
  66. * MAXFIND (OPTIONS):
  67. *
  68. *  MaxFind. Version 2.3   Copyright 1988,90 by Stan Peters
  69. *            Shareware, $15.       Box 2028, Fairfield, Iowa 94306
  70. *   Usage:  mf  [-options] string  [string].... filename [-options]
  71. *         Filename may contain ? and *, it may have a path prefix
  72. *         You may have 1 to 15 strings.
  73. *         A tilde (~) in a string matches any character.
  74. *         Options must start with a '- ', they may be first and/or last.
  75. *     Searching options:
  76. *        a - 'and', all must be present.  f - "fuzzy", approximate spelling.
  77. *        c - case sensitive search.       w - match only if a word.
  78. *        d - Span entire document, if necessary.
  79. *     Output options:
  80. *        l - show line numbers.      (*)   t - to screen and > file.    (*)
  81. *        m - stop after first match. (*)   u - Unix (grep) style output.(*)
  82. *        n - no pause each 24 lines. (*)
  83. *     Input options:
  84. *        b - also search binary files.    s - also include subdirectorys
  85. *        h - strip hi (8) bits.
  86. *     AND searches using "sliding windows":
  87. *        2 - 15  Window size (number of lines) for searching and displaying
  88. *
  89. *         afcwdbsh/ - OK with SM
  90. *
  91. *  A  /  indicates an OR within an AND, use  //  to find  / .
  92. *     Example:  Find Tom or Bob Jones from Texas in my address file
  93. *     Enter:   "mf  tom/bob jones texas  address.fil  -a4"
  94. *
  95. *     (*) - do not use with sm.bat, "ntl" are default options with sm.bat
  96.  
  97. * (NOTE):
  98. *     - @6 must be the first macro in this file to be used with sm.bat.
  99. *     - To use this macro in any directory, change /Esm.mac and
  100. *       /Lsm.mac in sm.bat to the location of sm.mac, eg change to
  101. *       /Ee:\up\sm.mac.
  102. *     - Enter other search or input options as %3 or at the option,
  103. *       prompt, eg "c" for case sensitive search without the minus.
  104. *     - Search is case insensitive unless option "c" is specified.
  105. *     - If no files are found containing the search text, a message
  106. *       "No text found" is displayed.
  107. *     - Macro will stop before completion if any line containing the
  108. *       search text also contains "g>". Macro cannot search for "g>".
  109. *     - This macro can be quite "noisy" if beeps are set on with
  110. *       QCONFIG, especially if there are many lines containing
  111. *       search text. We use "Find" to check each line of the output
  112. *       to determine whether it is a file name or found text. File
  113. *       names are not quite as "noisy". Testing this macro has forced
  114. *       me to set QEdit beeps "off"!
  115. *     - A minimum of of 55 bytes free environment space is needed to
  116. *       search for a 10 character string with 12 character file spec
  117. *       and 1 character option. I suggest you have at least a 100
  118. *       bytes free to be safe. Since the free environment space is
  119. *       considerably reduced when "shelling to DOS", sm.bat may not
  120. *       work properly when "shelled" from another program.
  121. *     - MaxFind writes to disk at least once for every file it
  122. *       searches. Therefore, for faster macro operation, replace c:\
  123. *       in sm.bat and sm.qm with your ram drive.
  124.  
  125. * (EXAMPLES):
  126.  
  127. *     a)  Example:  Load all files with extension "bat" or "tst"
  128. *                   containing "aaa"  and "bbb" in each file.
  129. *             (Must be run from input mode because of %1 %2 %3 defs.)
  130. *         Enter:    "sm" <enter>, and at the query prompts enter...
  131. *                         Search text   =aaa bbb
  132. *                         File name(s)  =*.??t
  133. *                         Option(s)     =
  134. *
  135. *     b)  Example:  Load all files with extension "tst" containing "ccc"
  136. *         Enter:   "sm ccc *.tst" <enter>
  137.  
  138. *     c)  Example:  Load all files containing "ddd" and "eee" only
  139. *                   within a 2 line window in each file, with extension
  140. *                   "tst".
  141. *                (Must be run from input mode because of %1 %2 %3 defs.)
  142. *         Enter:    "sm" <enter>, and at the query prompts enter...
  143. *                         Search text   =ddd eee
  144. *                         File name(s)  =*.tst
  145. *                         Option(s)     =a2
  146. *                   (sm.tst is included to test above examples)
  147.  
  148. * (INDEX) USE:
  149. * To locate a macro or item in this file, press @h, place the cursor
  150. * line on the desired item in the Index above, and press <enter>.
  151. * See BOOKxx.QM for more details.
  152.  
  153. * (MAXFIND) DESCRIPTION (extracted from MaxFind.doc):
  154. *      Basically, this program works much like other FIND programs
  155. *      that you may have used.  Enter the program name at the DOS
  156. *      prompt, followed by a string, and then the file name.  But
  157. *      there are several powerful advantages:
  158. *        - Search for up to 15 strings on one pass over the file with
  159. *          little performance penalty.
  160. *        - Combination and/or searches are definable in an easy to use way.
  161. *        - Will search subdirectories or the entire disk.
  162. *        - Has a "fuzzy" search, spelling need not be exact.
  163. *        - A help screen is available, enter  mf  <ENTER> at the DOS prompt.
  164. *        - It works quickly!  Now, with Version 2.3, simple searches on
  165. *          my 8 mHz AT disk scan at 100 thousand bytes per second.
  166. *          It moves at 70k bytes per second for quite complex searches.
  167. *        - A scan window size option for matching and display.  Great for
  168. *          Name and Address lists and for finding phrases or quotes that
  169. *          span more than one line.
  170. *        - It is useful on word processors documents and data bases that
  171. *          keep their data in an ASCII format.
  172.  
  173. *      The overall effect of this combination of features is a text
  174. *      search program, that in the words of PC magazine (1/31/89),
  175. *      "..holds its own with the best commercial programs."
  176. *
  177. *      Since then, Lotus has introduced Magellan, a shell with text
  178. *      search.  This $179 program will take two megabytes out of a
  179. *      20meg hard disk for an index to the entire disk.  I have
  180. *      looked at it briefly and I'm impressed.  Fast searches and
  181. *      "launching" into the appropriate program.  But I feel that
  182. *      anyone who needs that, should  ALSO  have MaxFind.  Because,
  183. *      after all, finding "lost" information is not an easy job with
  184. *      ANY program.  MaxFind is the preferred tool for these cases:
  185. *        - Names and words with unknown spelling.
  186. *        - Longer documents.  With my limited exposure to Magellan,
  187. *            it appears that it finds FILES very quickly, but its up
  188. *            to you to scroll through the document.  MaxFind will
  189. *            show you up to 24 found word(s), in context, on one
  190. *            screen.
  191. *        - Finding a quote.  Magellan doesn't index about 150 common
  192. *          words.  If many of these are in the quote - problems.
  193. *        - It won't fit on a floppy based laptop.
  194.  
  195. *----------------------------------------------------------------------
  196. * (PCED) synonymns to search from a file list
  197. *
  198. * MaxFind does not have the option of searching from a file list.
  199. * However PCED by Chris Dunford with the following synonyms using the
  200. * "@@file list" option will search from the file list "sm.lst".
  201. *
  202. * rem PCED synonyms for MaxFind Search, Syntax: SMC1 [search text]
  203. *
  204. *     SYN smc1     'cef^cancel &A^delc^mfc &A^qec^cen'
  205. *     SYN cancel   'if "&A" == "" CED CANCEL notxt'
  206. *     SYN notxt    'echo No search text, Syntax: SMC1 [search text]^cen'
  207. *     SYN cef      'CED ECHO OFF^echo off'
  208. *     SYN delc     'if exist c:\! del c:\!'
  209. *     SYN cen      'echo on^CED ECHO ON'
  210. *     SYN mfc      'mf.exe -ntl &A @@sm.lst>>c:\!'
  211. *     SYN qec      'q.exe c:\! /Esm.mac /Lsm.mac'
  212. * rem SYN mfc      'mf.exe -ntl &A @@e:\up\sm.lst>>c:\!'
  213. * rem SYN qec      'q.exe c:\! /Ee:\up\sm.mac /Le:\up\sm.mac'
  214.  
  215. * NOTE: Change "e:\up\" to the directory where sm.mac and sm.lst reside.
  216. * "REM" lines are my setup.
  217. *
  218. * You must have PCED v2.00 or later with the Filelist progam FL.EXE
  219. * loaded. These synonyms are in sm.sym and can be loaded with sm-syn.bat
  220.  
  221. * File list sm.lst is only one line "*.tst" for testing. To test,
  222. * type "smc1 aaa" <enter> after loading these synonyms. You should
  223. * see the following file loaded after the macro completes running:
  224. *
  225. * +- Searching> SM.TST
  226. * 3:aaa bbb ccc ddd eee fff ggg hhh iii jjj jjj lll mmm nnn ooo
  227.  
  228. * Here's the file list I keep in e:\up\sm.lst:
  229. *
  230. *                 *.qm
  231. *                 *.ql
  232. *                 *.inf
  233. *                 *.bat
  234. *                 *.lst
  235. *                 *.me
  236. *                 *.doc
  237. *                 *.syn
  238. *                 *.new
  239. *                 *.tst
  240. *                 e:\syn\sa.syn
  241. *                 u:\sr?.bat
  242.  
  243. * (OTHER) MACROS:
  244. *
  245. * See SRCxxx.QM in AMACxx.Zip for search and search/replace macros using
  246. * Chris Dunford's excellent FGREP.COM.com.
  247.  
  248.  
  249. * ******* (CAUTION) ***********
  250. *
  251. * Letters "S~~" and "R~~" must NOT occur in any other Dos environment
  252. * variable name or value.
  253. *
  254.  
  255. * (ENVIRONMENT) Variables - See SRCH29.QM for discussion               |K
  256.  
  257. * (REQUIRED) PROGRAM FILES
  258. *
  259. * You──MUST──have the exectable program files in AMAC-PRG.ZIP to run
  260. * some of these macros. AMAC-PRG.ZIP can be found on the following BBS's:
  261. *
  262. *                                 SemWare
  263. *                                 Exec-PC
  264. *
  265. * It can not be found on CompuServe since many of the programs are
  266. * Copyrighted. All program files are ShareWare, and inclusion in
  267. * AMAC-PRG.ZIP is not prohibited in their documentation.
  268. *
  269. * MAXFND23.ZIP and INPUT.ZIP are the only files necessary to run SM.BAT.
  270. *
  271. * INPUT can be found on Exec-PC as INPUT.ZIP. MAXFIND v2.3 can be found
  272. * on CompuServe IBMSYS Lib 3 as MAXFND.ZIP and on EXec-PC as
  273. * MAXFND23.ZIP
  274. *
  275. * AMAC-PRG.ZIP contains:
  276. * ----------------------
  277. * Name          Length    Method     SF   Size now  Mod Date
  278. * ============  ========  ========  ====  ========  =========
  279. * INPUT.ZIP         3097   Stored     0       3097  07 May 86
  280. * MAXFND23.ZIP     24247   Stored     0      24247  26 Apr 90
  281. * RJ.ZIP            9965   Stored     0       9965  01 Dec 90
  282. * FGREP172.ZIP     12513   Stored     0      12513  19 May 90
  283. * DX211.ZIP       100895   Stored     0     100895  17 Mar 89
  284. * AMAC-PRG.INF      3138  Imploded   67       1014  23 Apr 91
  285. * ============  ========  ========  ====  ========  =========
  286. * *total     6    153855  ZIP 1.10    0%    152329  23 Apr 91
  287. *
  288. * I thank the authors for these excellent programs.
  289.  
  290. * 
  291. * ----------------------------------------------------------------------
  292. * @(6) - Srch ONLY from command line, loads files w/sm.bat, no replace   *
  293. * -------------------- uses MaxFind mf.exe ----------------------------- *
  294. **** MUST BE THE FIRST MACRO IN THIS FILE TO BE USED WITH SM.BAT ****
  295. *
  296. @6 macrobegin
  297.         altwordset                      * For all file names
  298.         begfile                         * Just in case!
  299. * ----------------- delete MaxFind Copyright header -----------------*
  300.  header:                                *
  301.         find "xfind C" return return    * Find MaxFind header
  302.         jfalse end_header:              *
  303.         delline                         * Delete it until no more
  304.         jump header:                    *
  305.  end_header:                            *
  306. * --------- delete "Hex file skipped" message and file name ---------*
  307.         begfile                         * Back to tof
  308.  hex:                                   *
  309.         find "Hex file s" return return * Find "Hex file skipped" msg
  310.         jfalse end_hex:                 *
  311.         delline                         * Delete it until no more
  312.         cursorup                        * Move up to hex name
  313.         delline                         * Delete it
  314.         jump hex:                       * And do until done
  315.  end_hex:                               *
  316.         begfile                         * Back to tof
  317. * ------------------ delete file names with no text ------------------*
  318.  cleanup:                               *
  319.         begline                         * Position for find
  320.         unmarkblock                     *
  321.         markline markline               * Mark line to check if name
  322.         find "g>" return "L"  return    * Check if name
  323.         jtrue name:                     * If name, check if next line
  324.                                         * is also name
  325.         cursordown                      *ELSE move down to next line
  326.         jfalse end_cleanup:              * If can't move down, at eof
  327.         jump cleanup                    * Check this line if name
  328.  name:
  329.         cursordown                      * Is a file, move down to next
  330.                                         * line
  331.         jfalse delete:                  * If can't move down, at eof
  332.                                         * and it's a name, go delete it
  333.         cursorright                     *ELSE put cursor on >
  334.         unmarkblock                     *
  335.         markcolumn                      * Begin mark
  336.         cursorleft                      * Move left one space
  337.         markcolumn                      * Mark column to check for "g>"
  338.         cursorleft                      * Move to "n" in "Searching"
  339.         find "g>" return "L"  return    * Is line a name?
  340.         jfalse cleanup:                 * If not a name, go to cleanup
  341.         cursorup                        *ELSE must be text, move back
  342.                                         * up to where we were
  343.         jfalse end_cleanup:             * If can't move up, at tof
  344.         delline                         *ELSE Delete name with no text
  345.         jump cleanup:                   *
  346.  delete:                                *
  347.         delline                         * Delete last line if name
  348.  end_cleanup:                           *
  349. * -------------------- load file names with text --------------------*
  350.         endfile                         * Start to load at eof
  351.  load:                                  *
  352.         begline                         * Position for find
  353.         find "g>" return "B"  return    * Find line with file name
  354.         jfalse text:                    * No more file names? Move up
  355.         wordright *wordright wordright  * Move to file name
  356.         unmarkblock                     * Clear last mark
  357.         markcolumn                      * And begin mark
  358.         endline                         * Get all name in block
  359.         copy                            * Copy file name to scrap
  360.         EditFile                        * Get ready to load
  361.         CurrentFilename " "             * To force return *here*
  362.         Paste Return                    * Paste file name & do it!
  363.  text:
  364.         cursorup                        * Go to next line
  365.         jfalse end_load:                * No more file names? End load
  366.         jump load:                      *ELSE more files to load
  367.  end_load:                              *
  368. * --------------------- "No found text" message ---------------------*
  369.         cursordown cursorup             * Test if any search text found
  370.         jtrue find_set:                 * If found, move on
  371.         "No found text "                *ELSE no find, display this
  372.         jump end:                       * End macro if no found text
  373.  find_set:                              *
  374. * -------------------- initialize find for search --------------------*
  375.         editfile "c:\$" return          * Load tempfile
  376.         find  "S~~" return return      ** Find S~~ in SET output
  377.         find "=" return return          * Move to =
  378.         cursorright                     * Move first character
  379.         markcharacter                   * Mark it
  380.         endline                         * Move to end of text
  381.         copy                            * Copy search text to scrap
  382.         killfile quit                   * Kill/quit temp for next time
  383.         Find paste return Escape        * Initialize find for F4
  384. * ------------------------------ reset ------------------------------*
  385.  end: defaultwordset                    * Reset
  386. *
  387. * 233 bytes Wed  04-17-1991  16:35:04
  388. * 216 bytes Wed  04-24-1991  14:18:01 moved DOS "set>c:$" to SM.BAT
  389. *                                     replace R~~ with S~~
  390. * 221 bytes Tue  04-30-1991  22:28:02 changed initialize find routine
  391.  
  392.  
  393. * 
  394. * ----------------------------------------------------------------------
  395. * (f4) Finds search text in file after loading
  396. * ----------------------------------------------------------------------
  397. *
  398. f4 repeatfind
  399.  
  400. * 
  401. * ----------------------------------------------------------------------
  402. * (f5) prevfile
  403. * ----------------------------------------------------------------------
  404. *
  405. f5 prevfile
  406.  
  407. * 
  408. * ----------------------------------------------------------------------
  409. * (f6) nextfile
  410. * ----------------------------------------------------------------------
  411. *
  412. f6 nextfile
  413.  
  414. * 
  415. * ----------------------------------------------------------------------
  416. * @(h) Finds first word on cursor line marked in document below
  417. * ----------------------------------------------------------------------
  418. *
  419. * Press @ and h at the same time. Cursor down to desired line in Index.
  420. * Press <enter> to locate the desired item from the Index. See
  421. * Bookxx.Qm in AMACxx.Zip for more discussion.
  422. *
  423. @h macrobegin
  424.         begfile
  425.         unmarkblock
  426.         markline markline
  427.         pause
  428.         wordright
  429.         markword
  430.         copy
  431.         endpara
  432.         find "(" paste ")"  return return
  433.         begline
  434. *
  435. * 22 bytes Tue  04-09-1991  16:23:53
  436.  
  437. * (Version) history:
  438. *   A   -   Initial
  439. *   B   -   Modified "No found text" message handling.
  440. *       -   Wrong copy of sm.bat in AMAC-B.ZIP -corrected.
  441. *   C   -   Changed PCED synonym to show directory/path.
  442. *       -   Corrected @6 to handle "window" searches and initialize
  443. *           find for F4 correctly.
  444. *       -   Changed examples.
  445. *       -   Left sm.lst out of amac-c.zip, added it.
  446. *   D   -   Changed PCED synonyms to use "CED CANCEL".
  447. *   E   -   Changed find initialize FGS to FGR to find replacement
  448. *           text with F4 IN @6.
  449. *   F   -   Shortened SM.BAT by removing "Mode" output.
  450. *       -   Removed DelLine and UnMarkBlock from @6
  451. *   G   -   Moved DOS "set>c:$" to SM.BAT
  452. *       -   Corrected @6 find initialize FGR to FGS to find search
  453. *           text with F4 in @6.
  454. *   H   -   Changed FGR to R~~
  455. *       -   Changed FGS to S~~
  456. *       -   Changed initialize find routine in @6
  457. *   K   -   Added reference to environment variables.
  458. *   L   -   Minor documentation changes.
  459.  
  460. * Tom Hogshead
  461.